package com.lyfam.vaadin.model;

import java.io.Serializable;
import java.util.UUID;

import com.lyfam.annotation.UIBean;
import com.lyfam.annotation.UIField;
import com.lyfam.annotation.UIField.UIType;
import com.lyfam.vaadin.validator.ProjectNameValidator;
import com.lyfam.vaadin.view.form.DealProductDataProvider;
import com.lyfam.vaadin.view.form.DealProductValueChangedListener;
import com.lyfam.vaadin.view.form.DealSubProductValueChangedListener;

@UIBean(packageName="com.lyfam.vaadin.formfactory",
        className="DealFormFactory",
        wizards={"deal/deal", "deal/deal-step1"},
        customImport={"com.lyfam.vaadin.validator.ProjectNameValidator",
        "com.lyfam.vaadin.view.form.*"})
public class Deal implements Serializable
{
    private String dealId;
    
    @UIField(label="Project Name", type=UIType.TEXTBOX,
            validator=ProjectNameValidator.class, require=true)
    private String projectName;
    
    @UIField(label="Product", type=UIType.SELECT, refreshImmediate=true,
            valueChangedListener=DealProductValueChangedListener.class,
            dataProvider=DealProductDataProvider.class)
    private String product;
    
    @UIField(label="Sub Product", type=UIType.SELECT, refreshImmediate=true,
            valueChangedListener=DealSubProductValueChangedListener.class)
    private String subproduct;
    
    @UIField(label="Related Product", type=UIType.SELECT, hidden=true)
    private String relatedProduct;
    
    @UIField(label="Deal Status", type=UIType.SELECT)
    private String bankerDealStatus;
    
    @UIField(label="", type=UIType.CUSTOM_FIELD,
            customFieldFormFactoryClassname="com.lyfam.vaadin.formfactory.ClientFormFactory")
    private Client client = new Client();

    public Deal()
    {
        dealId = UUID.randomUUID().toString();
    }
    
    public String getProjectName()
    {
        return projectName;
    }

    public void setProjectName(String projectName)
    {
        this.projectName = projectName;
    }

    public String getProduct()
    {
        return product;
    }

    public void setProduct(String product)
    {
        this.product = product;
    }

    public String getSubproduct()
    {
        return subproduct;
    }

    public void setSubproduct(String subproduct)
    {
        this.subproduct = subproduct;
    }

    public String getBankerDealStatus()
    {
        return bankerDealStatus;
    }

    public void setBankerDealStatus(String bankerDealStatus)
    {
        this.bankerDealStatus = bankerDealStatus;
    }

    public Client getClient()
    {
        return client;
    }

    public void setClient(Client client)
    {
        this.client = client;
    }

    @Override
    public String toString()
    {
        return "Deal [" + (bankerDealStatus != null ? "bankerDealStatus=" + bankerDealStatus + ", " : "")
                + (client != null ? "client=" + client + ", " : "")
                + (product != null ? "product=" + product + ", " : "")
                + (projectName != null ? "projectName=" + projectName + ", " : "")
                + (relatedProduct != null ? "relatedProduct=" + relatedProduct + ", " : "")
                + (subproduct != null ? "subproduct=" + subproduct : "") + "]";
    }

    public String getRelatedProduct()
    {
        return relatedProduct;
    }

    public void setRelatedProduct(String relatedProduct)
    {
        this.relatedProduct = relatedProduct;
    }

    public String getDealId()
    {
        return dealId;
    }

    public void setDealId(String dealId)
    {
        this.dealId = dealId;
    }
}
